package com.sens.enums;

import com.sens.database.GlobalSharedPreferences;

/**
 * Created by SensYang on 2016/4/9 0009.
 */
public enum PreferencesSetting implements GlobalSharedPreferences.IPreferencesSetting {
    QUARTZ_TIME("quartz_time", 0L),
    ALIPAY_HOOK_LOG("alipay_hook_log", null),
    MYBANK_HOOK_LOG("mybank_hook_log", null),;
    private final String settingName;
    private final Object defaultValue;

    PreferencesSetting(String settingName, Object defaultValue) {
        this.settingName = settingName;
        this.defaultValue = defaultValue;
    }

    /**
     * 获取字段名
     */
    public String getName() {
        return settingName;
    }

    /**
     * 获取默认值
     */
    public Object getDefaultValue() {
        return defaultValue;
    }

    /**
     * 根据字段名字实例化
     */
    public static PreferencesSetting fromSetting(String settingName) {
        PreferencesSetting[] values = PreferencesSetting.values();
        for (PreferencesSetting value : values) {
            if (value.settingName.equalsIgnoreCase(settingName)) {
                return value;
            }
        }
        return null;
    }
}
